USE [QLDL]
GO

/****** Object:  UserDefinedFunction [dbo].[f_BaoCaoCongNo]    Script Date: 01/03/2011 15:32:33 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE function [dbo].[f_BaoCaoCongNo]
	(@Thang int, @Nam int)
returns @BangKetQua table
(	STT int identity(1, 1),
	DaiLy ntext,
	NoDau money,
	PhatSinh money,
	TienThu money,
	NoCuoi money
)
as
begin
	insert into @BangKetQua select TenDaiLy, NoDau, PhatSinh, TienThu, NoCuoi 
							from DAILY, CONGNO
							where (DAILY.MaDaiLy = CONGNO.MaDaiLy)
							 and (CONGNO.Thang = @Thang) 
							 and (CONGNO.Nam = @Nam)
							 order by CAST(TenDaiLy as nvarchar(200)) asc
	return
end
GO


